package com.buss.base.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.buss.core.dic.RecordStatus;
import com.buss.core.model.Role;

@Entity
@Table(name="base_branch")
@TableGenerator(name="branch_pk_sequence",initialValue=1,allocationSize=1,pkColumnName="seq_col",
pkColumnValue="branch_seq",valueColumnName="seq_val",table="base_pk_sequence")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JsonIgnoreProperties(value={"roles"})
public class Branch implements Serializable {

	private static final long serialVersionUID = -5349557810405390891L;

	/**库房编码*/
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator="branch_pk_sequence")
	private Long id;
	
	/**公司编码*/
	@Column(nullable=false,length=20)
	private String companyId;
	
	/**库房名称*/
	@Column(nullable=false,length=100)
	private String name;
	
	/**拼音全码*/
	@Column(nullable=false,length=1000)
	private String pinyin;
	
	/**拼音简码*/
	@Column(nullable=false,length=100)
	private String pinyinHead;
	
	/**库房地址*/
	@Column(length=200)
	private String address;
	
	/**库房联系人*/
	@Column(length=50)
	private String contact;
	
	/**联系电话号码*/
	@Column(length=50)
	private String contactNumber;
	
	/**qq号码*/
	@Column(length=50)
	private String qq;
	
	/**msn号码*/
	@Column(length=50)
	private String msn;
	
	/**阿里旺旺号码*/
	@Column(length=50)
	private String aliwangwang;
	
	/**电子邮件*/
	@Column(length=100)
	private String email;
	
	/**库房简介*/
	@Column(length=2000)
	private String intro;
	
	/**状态*/
	@Enumerated(value=EnumType.STRING)
	private RecordStatus status;
	
	/**排序序号*/
	private Long sortOrder;

	@JsonDeserialize
	@ManyToMany(cascade=CascadeType.REFRESH,fetch=FetchType.LAZY,mappedBy="branchs")
	private List<Role> roles;
	
	/**添加时间*/
	@Temporal(value=TemporalType.TIMESTAMP)
	@Column(nullable=false,updatable=false)
	private Date addDate;
	
	/**添加人*/
	@Column(nullable=false,length=50,updatable=false)
	private String addUser;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPinyin() {
		return pinyin;
	}

	public void setPinyin(String pinyin) {
		this.pinyin = pinyin;
	}

	public String getPinyinHead() {
		return pinyinHead;
	}

	public void setPinyinHead(String pinyinHead) {
		this.pinyinHead = pinyinHead;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getContactNumber() {
		return contactNumber;
	}

	public void setContactNumber(String contactNumber) {
		this.contactNumber = contactNumber;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public String getMsn() {
		return msn;
	}

	public void setMsn(String msn) {
		this.msn = msn;
	}

	public String getAliwangwang() {
		return aliwangwang;
	}

	public void setAliwangwang(String aliwangwang) {
		this.aliwangwang = aliwangwang;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public RecordStatus getStatus() {
		return status;
	}

	public void setStatus(RecordStatus status) {
		this.status = status;
	}

	public Long getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(Long sortOrder) {
		this.sortOrder = sortOrder;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public Date getAddDate() {
		return addDate;
	}

	public void setAddDate(Date addDate) {
		this.addDate = addDate;
	}

	public String getAddUser() {
		return addUser;
	}

	public void setAddUser(String addUser) {
		this.addUser = addUser;
	}
	
	
}